﻿package net.wangit.jdbc.sqltype;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import net.wangit.util.Checker;


/**
 * 可空SQL数据类型
 * 
 * @author watson
 * Feb 12, 2010
 */
@SuppressWarnings("serial")
public abstract class NullableSqlType implements SqlType {

	public NullableSqlType() {
	}

	public final void set(PreparedStatement st, String value, int index)
			throws SQLException {
		if (Checker.isEmpty(value))
			st.setNull(index, sqlType());
		else
			setNotNull(st, value, index);
	}

	protected abstract void setNotNull(PreparedStatement preparedstatement,
			String s, int i) throws SQLException;
}
